.cm-table-wrap {
    width: 100%;
    position: relative;
}

.cm-table-border {
    &::after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        z-index: 2;
        border: 1px solid rgb(var(--cui-grey-1));
        pointer-events: none;
    }

    td,
    th {
        border-right: 1px solid rgb(var(--cui-grey-1));
    }
}

.cm-table {
    width: 100%;
    color: var(--cui-color-text-1);
    font-size: 14px;
    overflow: hidden;
    position: relative;

    table {
        white-space: nowrap;
        margin: 0;
        width: 100%;
        border: none;
        border-collapse: separate;
        border-spacing: 0;
        table-layout: fixed;
    }

    td,
    th {
        min-width: 0;
        height: 48px;
        box-sizing: border-box;
        text-align: left;
        text-overflow: ellipsis;
        vertical-align: middle;
        border-bottom: 1px solid var(--cui-color-border);
    }

    td {
        background-color: var(--cui-color-bg-1);
        transition: background-color .2s ease-in-out;
    }

    .cm-table-header,
    th {
        white-space: nowrap;
        background-color: var(--cui-color-th-bg);
    }

    .cm-table-summary,
    .cm-table-summary td {
        background-color: var(--cui-color-th-bg);
        border-bottom: none;
    }

    .cm-table-cell-fixed-left-last {
        -webkit-box-shadow: 2px 0 0 0 rgba(0, 0, 0, .04);
        box-shadow: 2px 0 0 0 rgba(0, 0, 0, .04);
        border-right: 1px solid rgba(0, 0, 0, 0.12);
    }

    .cm-table-cell-fixed-right-first {
        -webkit-box-shadow: -2px 0 0 0 rgba(0, 0, 0, .04);
        box-shadow: -2px 0 0 0 rgba(0, 0, 0, .04);
        border-left: 1px solid rgba(0, 0, 0, 0.12);
    }

    tbody tr {

        &.cm-table-row-selected,
        &:hover {
            td {
                background-image: linear-gradient(0deg, var(--cui-color-fill-0), var(--cui-color-fill-0));
            }
        }
    }
}

.cm-table-stripe tbody {
    tr.cm-table-row-even td {
        background-image: linear-gradient(0deg, var(--cui-color-fill-0), var(--cui-color-fill-0));
    }

    tr.cm-table-row-selected td,
    tr:hover td {
        background-image: linear-gradient(0deg, var(--cui-color-fill-1), var(--cui-color-fill-1));
    }
}

.cm-table-sort {
    height: 20px;
    display: inline-flex;
    flex-direction: column;
    position: relative;
    margin-top: -1px;
    margin-left: 3px;

    .cm-icon {
        height: 8px;
        cursor: pointer;
        color: rgb(var(--cui-grey-2));

        &.cm-table-sort-active {
            color: var(--cui-primary-color);
        }
    }
}

.cm-table-cell {
    padding-left: 18px;
    padding-right: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    box-sizing: border-box;
    display: flex;
    align-items: center;

    .cm-checkbox {
        margin-right: 0px;

        .cm-checkbox-outter {
            margin: 0;
        }
    }
}

.cm-table-cell-tooltip-content,
.cm-table-cell-ellipsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cm-table-cell-tooltip.cm-popover-inner {
    min-width: 150px;
    white-space: pre-wrap;
    word-break: break-all;
}

.cm-table-small {
    .cm-table {
        font-size: 12px;
    }

    td,
    th {
        height: 40px;
    }
}

.cm-table-tree-icon {
    margin-right: 3px;
    cursor: pointer;
    color: rgb(var(--cui-grey-3));
}

.cm-table-tree-icon-empty {
    display: inline-flex;
    width: 14px;
    margin-right: 3px;
}

.cm-table-expand {
    cursor: pointer;
    color: rgb(var(--cui-grey-3));
    transition: all 0.2s linear;

    &.cm-table-expand-open {
        transform: rotate(90deg);
    }
}

.cm-table-head-col {
    position: relative;
}

.cm-table-resizing {
    -webkit-user-select: none;
    user-select: none;
}

.cm-table-resize {
    height: 100%;
    position: absolute;
    right: 0;
    width: 3px;
    cursor: col-resize;
}

.cm-table-resize-helper {
    display: none;
    position: absolute;
    height: 100%;
    left: 50px;
    z-index: 5;
    border-right: 1px dashed rgb(var(--cui-grey-3));
}

.cm-table-emprty-cell {
    text-align: center;
    color: rgb(var(--cui-grey-3));
}

.cm-table-header {
    &::-webkit-scrollbar {
        background-color: transparent;
        border-bottom: 1px solid var(--cui-color-border);
    }
}

.cm-table-summary {
    overflow-x: hidden;
    position: sticky;
    bottom: 0px;
    z-index: 2;

    &::before {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        z-index: 2;
        border-top: 1px solid var(--cui-color-border);
        pointer-events: none;
    }

    &::-webkit-scrollbar {
        background-color: transparent;
        border-top: 1px solid var(--cui-color-border);
    }
}

.cm-table-title {
    padding: 16px;
    border-bottom: 1px solid rgb(var(--cui-grey-1));
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    color: var(--cui-color-text-1);
}

.cm-table-footer {
    padding: 16px;
    border-top: 1px solid rgb(var(--cui-grey-1));
    background-color: var(--cui-color-fill-0);
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    color: var(--cui-color-text-1);
}

.cm-table-border {
    &.cm-table-with-title {
        &::after {
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
        }
    }

    &.cm-table-with-footer {
        &::after {
            border-bottom-left-radius: 4px;
            border-bottom-right-radius: 4px;
        }
    }
}

.cm-table-with-summary {
    .cm-table-body {
        tr:last-child {
            td {
                border-bottom: none;
            }
        }
    }
}